#include <cstdio>

int main() {
    const int N = 54;
    char mp[5] = {'S', 'H', 'C', 'D', 'J'};
    int next[N+1], start[N+1], end[N+1];
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= N; i++) {
        start[i] = i;
    }
    for (int i = 1; i <= N; i++) {
        scanf("%d", &next[i]);
    }

    while(n--) {
        for (int i = 1; i <= N; i++) {
            end[next[i]] = start[i];
        }
        for (int i = 1; i <= N; i++) {
            start[i] = end[i];
        }
    }

    for (int i = 1; i <= N; i++) {
        end[i]--;
        printf("%c%d%c", mp[end[i] / 13], end[i]%13+1, i==N?'\n': ' ');
    }

    return 0;
}